<?php
class Model_Admin_Search extends Model{

    public function getInfo($username,$keyword,$offset,$pageSize){

        $sql="select count(1)total
             from search t
             where t.isdeleted<>'1'
             and t.keyword like '%$keyword%'";

        $total=DB::query(Database::SELECT,$sql)->execute()->get("total");

        $sql="select t.searchid id,t.username,t.keyword,t.createdon
             from search t
             where t.isdeleted<>'1'
             and t.keyword like '%$keyword%'
             order by t.createdon desc limit $offset,$pageSize";


        $data=DB::query(Database::SELECT,$sql)->execute()->as_array();

        return array("total"=>$total,"rows"=>$data);
    }
}